package com.yuwei.yurpc.proxy;

import com.yuwei.yurpc.RpcApplication;

import java.lang.reflect.Proxy;

/**
 * 用户服务
 *
 * @author yuwei
 * @date 18:06 2024/10/3
 */
public class ServiceProxyFactory {
    public static <T> T getProxy(Class<T> clazz) {
        if (RpcApplication.getRpcConfig().getMock()) {
            return (T) Proxy.newProxyInstance(clazz.getClassLoader(),
                    new Class[]{clazz},
                    new MockServiceProxy());
        }

        return (T) Proxy.newProxyInstance(clazz.getClassLoader(),
                new Class[]{clazz},
                new ServiceProxy());
    }
}
